package com.qimu.saiyou.model.vo;

import com.baomidou.mybatisplus.annotation.TableName;
import com.qimu.saiyou.model.entity.QuestionAnswer;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 答案
 *
 * @TableName question_answer
 */
@TableName(value = "question_answer")
@Data
public class QuestionAnswerVO implements Serializable {
    /**
     * id
     */
    private Long id;

    /**
     * 题目ID
     */
    private Long questionId;
    private boolean isSelect;

    /**
     * 是否正确
     */
    private Integer isRight;
    /**
     * 答案内容
     */
    private String content;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 是否删除
     */
    private Integer isDelete;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 包装类转对象
     *
     * @param questionAnswerVO 问答
     * @return {@link QuestionAnswerVO}
     */
    public static QuestionAnswer voToObj(QuestionAnswerVO questionAnswerVO) {
        if (questionAnswerVO == null) {
            return null;
        }
        QuestionAnswer questionAnswer = new QuestionAnswer();
        BeanUtils.copyProperties(questionAnswerVO, questionAnswer);
        return questionAnswer;
    }

    /**
     * 对象转包装类
     *
     * @return
     */
    public static QuestionAnswerVO objToVo(QuestionAnswer questionAnswer) {
        if (questionAnswer == null) {
            return null;
        }
        QuestionAnswerVO questionAnswerVO = new QuestionAnswerVO();
        BeanUtils.copyProperties(questionAnswer, questionAnswerVO);
        return questionAnswerVO;
    }

    public static QuestionAnswerVO objToNoRightVo(QuestionAnswer questionAnswer) {
        if (questionAnswer == null) {
            return null;
        }
        QuestionAnswerVO questionAnswerVO = new QuestionAnswerVO();
        BeanUtils.copyProperties(questionAnswer, questionAnswerVO);
        questionAnswerVO.setIsRight(null);
        return questionAnswerVO;
    }

    private static final long serialVersionUID = 1L;
}